package com.huxiu.utils;

import android.content.Context;
import android.content.res.Resources;
import android.util.Log;

import com.huxiu.R;

/**
 * Created by caoyuanjing on 15/12/8.
 */
public class TextViewUtil {
    public Context mContext;
    public Resources mResources;

    public TextViewUtil(Context mContext) {
        this.mContext = mContext;
        mResources = mContext.getResources();
    }


    public static boolean isIndexStr(String str, String index) {
        str = str.substring(str.length() - 10);
        if (str.indexOf(index) != -1) {
            return true;
        }
        return false;
    }


    public String getStringIndex(String str) {
        if (isIndexStr(str, mResources.getString(R.string.click_now_look))) {
            return mResources.getString(R.string.click_now_look);
        } else if (isIndexStr(str, mResources.getString(R.string.click_here))) {
            return mResources.getString(R.string.click_here);
        }
        return null;
    }

    public String getContent(String str, String index) {
        str = str.substring(0, str.length() - index.length());
        return str;
    }
    public static boolean isReplyEntity(String name, String str) {
        if (str.length() > name.length()) {
            if (isContain(str,name)){
                str = str.substring(name.length(), str.length()).trim();
                Log.e("str","length"+str.length());
                Log.e("str","str"+str);
                if (str == null || str.length() == 0) {
                    return true;
                } else {
                    return false;
                }
            } else {
                if (str == null || str.length() == 0)
                    return true;
                else {
                    return false;
                }
            }
        } else {
            if (str == null || str.length() == 0)
                return true;
            else {
                return false;
            }
        }
    }
    public static boolean isContain(String str,String name) {
        return str.contains(name);
    }

}
